package com.cgly.medical.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @program: medical
 * @description: Swagger配置类
 * @author: chen di
 * @create: 2022-08-12 15:56
 */
@Configuration
@EnableSwagger2//启用Swagger2
public class SwaggerConfig {

    /**
     * 返回文档需要汇总的信息对象
     * @return
     */
    @Bean
    public Docket webApiConfig(){
        return new Docket (DocumentationType.SWAGGER_2)
                .groupName ("Medical-API")
                .apiInfo (webApiInfo())
                .select()
                .paths (Predicates.not (PathSelectors.regex ("/ admin/.*")))
                .paths (Predicates.not(PathSelectors.regex (" /error.*")))
//                .apis(RequestHandlerSelectors.basePackage("com.cgly.medical.controller"))
                .build();
    }

    /**
     * 定义了网页文档标题、描述、版本信息；
     * @return
     */
    private ApiInfo webApiInfo(){
        return new ApiInfoBuilder()
                .title("创新骨科临床应用系统-API文档")
                .description("本文档描述了创新骨科临床应用系统的接口定义")
                .version("1.0")
                .contact(new Contact("QST","http://www.itshixun.com/","3212502557@qq.com"))
                .build();
    }
}